﻿@page "/about/{Show}"
@using System.Reflection
@using System.Diagnostics
@using Gurux.DLMS.AMI.Module
@using Gurux.DLMS.AMI.Shared.Rest
@inject HttpClient Http
@if (Visible)
{
    <Dialog CancelButtonTitle="@Properties.Resources.Close"
    OnCancel="Close"    
    Title="@Properties.Resources.AboutTitle">
        <p>
            &emsp;&emsp;@Properties.Resources.Version&nbsp;@Version
        </p>
        <p>
            &emsp;&emsp;@Properties.Resources.Copyright&nbsp;1998-@Year&nbsp;Gurux Ltd.
            <br>
            &emsp;&emsp;@Properties.Resources.CopyrightAllRightsReserved
        </p>
        <p>
            &emsp;&emsp;@Properties.Resources.AboutInfo
            <br />
            &emsp;&emsp;<a href="https://www.gurux.fi" target="_blank">https://www.gurux.fi</a>
        </p>
        <br />
        <br />
        <img src="footer.png" style="position: absolute; bottom: 0px; left: 0px; height: 3px; width: 100%" />
        <img src="leaf.png" style="position: absolute; bottom: 0px; left: 0px " />
        <img src="factory.png" style="position: absolute; bottom: 0px; right: 0px " />
    </Dialog>
}
@code {
    [Parameter]
    public string Show
    {
        get
        {
            return Visible.ToString();
        }
        set
        {
            Visible = true;
        }
    }

    /// <summary>
    /// Is about window shown.
    /// </summary>
    bool Visible
    {
        get;
        set;
    }

    /// <summary>
    /// Version number
    /// </summary>
    string? Version
    {
        get;
        set;
    }

    /// <summary>
    /// .
    /// </summary>
    string Year
    {
        get
        {
            return DateTime.Now.Year.ToString();
        }
    }

    public void Close()
    {
        Visible = false;
        StateHasChanged();
    }

    protected override async Task OnInitializedAsync()
    {
        HttpResponseMessage response = await Http.GetAsync("api/Configuration/Version");
        ClientHelpers.ValidateStatusCode(response);
        Version = await response.Content.ReadAsStringAsync();
    }
}